package com.keba.lamp.test.vo.save;


import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Digits;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.FutureOrPresent;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Negative;
import jakarta.validation.constraints.NegativeOrZero;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import jakarta.validation.constraints.Past;
import jakarta.validation.constraints.PastOrPresent;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.ToString;
import com.keba.basic.annotation.constraints.NotEmptyPattern;
import com.keba.lamp.test.enumeration.ProductType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;

import static com.keba.basic.utils.ValidatorUtil.REGEX_USERNAME;

@Data
@ToString
public class RulesVO implements Serializable {
    @NotNull(message = "日期1不能为空")
    private Date date;
    @NotNull(message = "日期2不能为空")
    private LocalDateTime localDateTime;
    @NotNull(message = "日期3不能为空")
    private LocalDate localDate;
    @NotNull(message = "日期4不能为空")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private LocalTime localTime;
    @Schema(description = "将来时间")
    @Future(message = "将来日期")
    private LocalDate test5;
    @Schema(description = "将来日期")
    @FutureOrPresent(message = "将来日期或今天")
    private LocalDate test7;
    @Schema(description = "日期")
    @Past(message = "过去的时间")
    private LocalDateTime test6;
    @Schema(description = "test8")
    @PastOrPresent(message = "只能是过去的日期或今天")
    private LocalDate test8;


    /**
     * 名称
     */
    @Schema(description = "名称")
    @NotEmpty(message = "请填写名称")
    @Size(max = 24, message = "名称长度不能超过{max}")
    private String name;

    @NotBlank(message = "请填写名称，不能是空字符串")
    private String name2;


    /**
     * 商品类型;
     * #ProductType{ordinary:普通;gift:赠品}
     */
    @Schema(description = "商品类型")
    @NotNull(message = "请填写商品类型")
    private ProductType type;

    /**
     * 状态
     */
    @Schema(description = "状态")
    @AssertTrue(message = "状态必须为true")
    private Boolean state;
    @AssertFalse(message = "状态2必须为false")
    private Boolean state2;


    // 使用@Email默认的正则，前端校验会出错，所以在lamp-validator-start 模块对默认的正则做了替换
    @Email(message = "不符合邮件规则")
    private String email;
    @Pattern(regexp = REGEX_USERNAME, message = "不符合正则表达式规则")
    private String email2;
    @NotEmptyPattern(regexp = REGEX_USERNAME, message = "不符合正则表达式规则")
    private String email3;


    @Schema(description = "库存")
    @NotNull(message = "请填写库存")
    private Integer stock;
    @Null(message = "不能填写库存")
    private Integer stock2;
    @DecimalMax(value = "231.1234", message = "不能超过{value}")
    @DecimalMin(value = "2.1234", message = "不能小于{value}")
    private BigDecimal de1;
    @Schema(description = "测试")
    @Digits(integer = 3, fraction = 4, message = "整数位不能超过{integer}, 小数位不能超过{fraction}")
    private Double test4;
    @Schema(description = "父id")
    @Max(value = 20, message = "不能超过{value}")
    @Min(value = 2, message = "不能小于{value}")
    private Long parentId;
    @Negative(message = "只能是负数")
    private Integer int1;
    @NegativeOrZero(message = "只能是负数或0")
    private Integer int2;
    @Positive(message = "只能是正数")
    private Integer int3;
    @PositiveOrZero(message = "只能是正数或0")
    private Integer int4;

}
